
<%
Private Function GetLeftMenuByUserID(UserId, res_page_code)
''查找某个用户对应的权限对应的资源的信息，生成左侧菜单
''Response.Write "--<<<" & UserId & "-----" & resPPath & ">>>---"
	Dim rsObjT,strSql
	Set rsObjT = Server.CreateObject("ADODB.Recordset")
	
	strSql=""
	strSql=strSql & " SELECT DISTINCT "
	strSql=strSql & " T_RES.menu_name, T_RES.menu_code, T_RES.menu_num, T_RES.res_url, "
	strSql=strSql & " T_RES.res_ppath, T_RES.menu_show, T_RES_1.menu_name AS Expr1 "
	strSql=strSql & " , sel=CASE  WHEN T_RES_1.menu_name =T_RES.menu_name THEN 'on' ELSE ''  END "
	strSql=strSql & " ,  T_RES_2.menu_name AS pmenu_name "
	strSql=strSql & " FROM T_RES INNER JOIN "
	strSql=strSql & " (SELECT *, T_RES.res_ppath + CAST(T_RES.id AS varchar(5)) + '_' AS p_path "
	strSql=strSql & " FROM T_RES WHERE (T_RES.res_num = '"&res_page_code&"')) T_RES_1 ON "
	strSql=strSql & " T_RES.res_ppath = Left(T_RES_1.p_path,Len(T_RES.res_ppath)) INNER JOIN "
	strSql=strSql & " T_ROLE_RES ON T_RES.id = T_ROLE_RES.res_id INNER JOIN "
	strSql=strSql & " T_USER_ROLE ON T_ROLE_RES.role_id = T_USER_ROLE.role_id "
	strSql=strSql & " INNER JOIN T_RES T_RES_2 ON T_RES.res_ppath = T_RES_2.res_ppath + CAST(T_RES_2.id AS varchar(5))+ '_' "
	strSql=strSql & " WHERE (T_RES.menu_show = 1) AND (T_USER_ROLE.user_id = '"&UserId&"') "
	strSql=strSql & " ORDER BY T_RES.menu_num "

	''Response.Write strSql&"-----<br>"
	rsObjT.Open strSql, Conn, 1, 3
	If rsObjT.BOF And rsObjT.EOF Then 
			'nothing
		'end if	 
		'UserID=ReplaceBadChar(Trim(rsObjT("UserID")))
 	else
		Dim menuHtml 
		menuHtml="" 
		menuHtml="<h2>"&rsObjT("pmenu_name")&"</h2><ul>" 
		Do While Not rsObjT.EOF 	  	 	
			menuHtml=menuHtml & "<li class='"&rsObjT("sel")&"'><h3><a href='"&rsObjT("res_url")&"'>"&rsObjT("menu_name")&"</a></h3></li>"
	 		rsObjT.MoveNext 
	  	Loop
	   	''Response.Write "-----<br><br>" & strHtml &"<br><br>-----"
	end if 
	rsObjT.close
	''Set rsObjT = Nothing 
 	''释放数据库链接
	''call CloseConn	 

	GetLeftMenuByUserID = menuHtml&"</ul>"
End Function
%>


<!--begin left menu-->
<!--	
	<div class="c_left">
		<h2>权限管理</h2>
		<ul>		
			<li class="on"><h3><a href="/admin/users.asp">用户</a></h3></li>
			<li><h3><a href="/admin/roles.asp">角色</a></h3></li>
			<li><h3><a href="/admin/resources.asp">资源</a></h3></li>
		</ul>
	</div>
--> 

	 <% ''Response.Write "--------respagecode----"&respagecode &"-----------<BR>"	%>
	 <% Response.Write ""&GetLeftMenuByUserID(Session("UserID"),respagecode)%>
 
 
<!--end left menu-->




 